//
//  BaseViewController.swift
//  微博三天
//
//  Created by jessica on 15/11/13.
//  Copyright © 2015年 jessica. All rights reserved.
//

import UIKit


//tabBarController导航部分
class MainTableViewController: UITabBarController {
    
    
    @objc func composeDidClick(){
    
    
    print(__FUNCTION__)
        
    
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //KVC必须哦,否则不显示呢
        let AddBtn = MaintabBar()
        
        setValue(AddBtn, forKey: "tabBar")
        
        //打印按钮类名
        print(tabBar.classForCoder)
      // 加号按钮 点击事件
        
//        AddBtn.composeBtn.addTarget(self, action: "composeDidClick", forControlEvents: .TouchUpInside)
        
        //composeBtn懒加载的时候不要private 否则访问不到
        AddBtn.composeBtn.addTarget(self, action: "composeDidClick", forControlEvents: .TouchUpInside)

        addChildViewControllers()

    }

    
    private func addChildViewController(childController: UIViewController,title : String, imageName : String) {
        
        
        let nav = UINavigationController(rootViewController: childController)
        
        childController.title = title
        
        childController.tabBarItem.image = UIImage(named: imageName)
        
        addChildViewController(nav)
        
    }
    
    private func addChildViewControllers() {
        
        
        addChildViewController(HomeTableViewController(), title: "首页", imageName: "tabbar_home")
        
       addChildViewController(DiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(MessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        
        addChildViewController(ProfileTableViewController(), title: "我", imageName: "tabbar_profile")
    }
}
